import Login from "@/views/Login.vue";
import Layout from "@/views/Layout.vue";
import {createRouter, createWebHistory} from "vue-router";

import AdminLayout from "@/views/AdminLayout.vue";
import UserInfo from "@/views/user/UserInfo.vue";
import UserManagement from "@/views/admin/UserManagement.vue";
import RoomManagement from "@/views/admin/RoomManagement.vue";
import DrinksManagement from "@/views/admin/DrinksManagement.vue";
import EmployeeManagement from "@/views/admin/EmployeeManagement.vue";
import OrderManagement from "@/views/admin/OrderManagement.vue";
import Comments from "@/views/user/Comments.vue";
import DrinksPurchase from "@/views/user/DrinksPurchase.vue";
import Count from "@/views/admin/Count.vue";
import MemberManagement from "@/views/admin/MemberManagement.vue";
import MemberPurchase from "@/views/user/MemberPurchase.vue";
import CheckinManagement from "@/views/admin/CheckinManagement.vue";
import Checkin from "@/views/user/Checkin.vue";
import CheckOut from "@/views/user/CheckOut.vue";

//绑定url和页面
// 定义路由关系
const routes = [
    {path: '/login', component: Login},
    {
        path: '/',
        redirect: '/login',
        component: Layout,
        // 子路由
        children: [
            {path: '/user/userInfo', component: UserInfo},
            {path: '/user/comments', component: Comments},
            {path: '/user/drinksPurchase', component: DrinksPurchase},
            {path: '/user/memberPurchase', component: MemberPurchase},
            {path: '/user/checkin', component: Checkin},
            {path: '/user/checkout', component: CheckOut}
        ]
    },
    {
        path: '/',
        redirect: '/login',
        component: AdminLayout,
        // 子路由
        children: [
            {path: '/admin/userManagement', component: UserManagement},
            {path: '/admin/roomManagement', component: RoomManagement},
            {path: '/admin/drinksManagement', component: DrinksManagement},
            {path: '/admin/employeeManagement', component: EmployeeManagement},
            {path: '/admin/orderManagement', component: OrderManagement},
            {path: '/admin/memberManagement', component: MemberManagement},
            {path: '/admin/checkinManagement', component: CheckinManagement},
            {path: '/admin/count', component: Count}
        ]
    },
]

// 创建路由器
const router = createRouter({
    history: createWebHistory(), // 路由模式
    routes: routes
})

//导出暴露
export default router